package org.jsets.fastboot.persistent.config;

import org.jsets.fastboot.util.ThreadLocals;

/**
 * 
 * 结果集处理上下文
 * 
 * @author wangjie
 *
 */
public class PersistentContext {

	private static final String PERMIT_DESENSITIZE = "desensitize";
	private static final String PERMIT_ENCRYPT = "encrypt";
	private static final String PERMIT_DECRYPT = "decrypt";

	public static void permitDesensitize() {
		ThreadLocals.put(PERMIT_DESENSITIZE, true);
	}

	public static void permitEncrypt() {
		ThreadLocals.put(PERMIT_ENCRYPT, true);
	}

	public static void permitDecrypt() {
		ThreadLocals.put(PERMIT_DECRYPT, true);
	}

	public static boolean isDesensitizeNecessary() {
		return ThreadLocals.containsKey(PERMIT_DESENSITIZE);
	}

	public static boolean isEncryptNecessary() {
		return ThreadLocals.containsKey(PERMIT_ENCRYPT);
	}

	public static boolean isDecryptNecessary() {
		return ThreadLocals.containsKey(PERMIT_DECRYPT);
	}

	public static void cleanup() {
		ThreadLocals.cleanup();
	}

}